package com.alibaba.dubbo.spi.dubbo;

import com.alibaba.dubbo.common.extension.ExtensionLoader;
import com.alibaba.dubbo.common.extension.SPI;
import com.alibaba.dubbo.common.compiler.Compiler;

/**
 * @author zhangjuntao
 * @version V1.0
 * @Title ${CLASS_NAME}
 * @Description dubbo spi 实现。
 * @date 2017-11-13 下午1:47
 * @see SPI  spi接口的注解
 */
public class SPIMain {

    public static void main(String[] args) {

        /**
         * @SPI("service1")
         * 得到默认的service1的拓展实现实例
         */
        SPIService adaptiveExtension = ExtensionLoader.getExtensionLoader(SPIService.class).getDefaultExtension();
        adaptiveExtension.echo("ssssss");



        /**
         * @Adaptive
         * com.alibaba.dubbo.common.compiler.support.AdaptiveCompiler
         *
         * PS: 默认注解上AdaptiveCompiler上有@Adaptive注解，会作为Compiler的扩展实现，不用生成字节码.......
         */
        Compiler compiler = ExtensionLoader.getExtensionLoader(Compiler.class).getAdaptiveExtension();
        System.err.println(compiler);


        compiler.compile(null,Thread.currentThread().getContextClassLoader());

    }
}
